<?php 
/**
 *  File Defination 
 *  - Admin Panel Tool bar
 -------------------------------------------------------------------  
 *  Apprain : Content Management Framework <http://www.apprain.com/>
 *  Download link: http://www.apprain.com/download
 *  Docs link: http://www.apprain.com/docs
 -------------------------------------------------------------------
 *  License text http://www.opensource.org/licenses/mit-license.php 
 *  About MIT license <http://en.wikipedia.org/wiki/MIT_License/>
 */


    $ext_class = isset( $file2editcontent ) ? 'displaynone"' :""; 

    echo $this->get_tag('div',array('id'=>'hidden_content','class'=>"$ext_class"));
        echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back")) ,"title" => "Code editor")); 

        $pathback = substr($base_path,0,strrpos($base_path,'/')); 

        $data[] = array(App::load("Helper/Html")->linkTag($this->baseurl('/developer/editor/' . base64_encode( $pathback )),'Back'),
        App::load("Helper/Html")->linkTag($this->baseurl('/developer/editor/' . base64_encode( $pathback )),App::load("Helper/Html")->imgTag($this->baseurl('/images/admin/back.gif'))));
        
    $Grid = App::Module('DataGrid');
    if( !empty($dir_listing['dir']))
    {
        foreach( $dir_listing['dir'] as $key => $val )
        {
            $name = $val["name"];
            $type = $val["type"];
            $Grid->addRow( ' <a href="' . $this->baseurl('/') . 'developer/editor/' . base64_encode( $base_path . '/' . $name ) .  '">'. $name . '</a></label>',
                            ' <a href="' . $this->baseurl('/') . 'developer/editor/' . base64_encode( $base_path . '/' . $name ) .  '"><img src="' . $this->baseurl('/') . '/images/admin/folder.gif" title="Enter" alt="Enter" /></a></label>'
                            );				
        }
        
    }

    if( !empty($dir_listing['file']))
    {
        foreach( $dir_listing['file'] as $key => $val )
        {
            $base_path = ( $base_path != "") ? $base_path : "/";
            $name = $val["name"];
            $type = $val["type"];
            $Grid->addRow( '<label><a href="' . $this->baseurl('/') . 'developer/editor/' . base64_encode( $base_path ) .  '/' . base64_encode($name) . '">' . $name .'</a></label>',
                            '<label><a href="' . $this->baseurl('/') . 'developer/editor/' . base64_encode( $base_path ) .  '/' . base64_encode($name) . '"><img src="' . $this->baseurl('/') . '/images/admin/edit.gif" title="Edit ' . $val['name'] .  '" alt="Edit" /></a></label>'
                            );				
        }
    }
        if( !empty($data) )
        {
                $Grid->Render();
        }
        else
        {
            echo $this->callElement('common/message', array('caption' =>'Message','type' => 'error', 'message' => 'No Data found for Account'));
        }
     echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back")) ,"title" => NULL)); 
     echo '<br /><br />';
    echo $this->get_tag('/div');

    if( isset( $file2editcontent ) ) 
    {
        echo '<script type="text/javascript">
            window.addEvent("domready", function() {
                var myVerticalSlide = new Fx.Slide("hidden_content").show();
                $$(".view_hidden_content").addEvent("click", function(e){

                    e.stop();
                    $("hidden_content").setStyle("display", "block");
                    myVerticalSlide.toggle();
                });	
            });
        </script>';
        echo $this->get_tag('form',array('class'=>'app_form','method'=>'post'));
            echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"view_hidden_content"), array("type"=>"save"),array("type"=>"back")) ,"title" => "Path: " .$filepath)); 
            
            if( $message ):
                echo $this->callElement('default/tools/message', array('caption' =>'Message','type' => 'error', 'message' => $message));
            endif;

            echo App::load("Helper/Html")->textareaTag("data[Editor][content]",htmlspecialchars($file2editcontent),array("class"=>"app_input","style"=>"width:99%","rows" => "30"));
            echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back"),array("type"=>"save")) ,"title" => NULL)); 
        echo $this->get_tag("/form");
    }


?>